Skip to content

Conversation

@michaelnebel
Copy link
Contributor

@michaelnebel michaelnebel commented Oct 9, 2025

In this PR we update the extractor to only extract the location of Fields, Parameters, Constructors, Destructors and Operators in the current context and update the QL library to use these locations instead (this will then be the location of the unbound declaration). This is the final change required for converting the extractor to use * IDs for source locations (we still need to look into assembly locations) when running in BMN.

Details

Furthermore, for constructors there is an extra complication: We are only extracting a single best location for implicitly declared constructors (otherwise implicit constructors for partial classes will have multiple locations). I decided to keep the semantics as they were (and still only extract a single location). (@hvitved - this is related to our offline discussion on this topic).

Changes to tests.

There are some updates to the locations for tuple related fields. This is because we are now using the unbound declaration location (which is not in source for a value tuple). I changed one of the tests to use whether the tuple type is in source (instead of the fields, which are definitely not - not even prior to this change) to get some output. However, as it is mentioned in the extractor, Roslyn reports locations of tuple types somewhat inconsistent (sometimes it is in source and sometimes it is not), which explains the "missing" results in the TupleTypes test.

DCA

  • BMN:
    • No changes to results.
    • No changes in performance.
    • Reduction in TRAP size of around 2%.
  • Traced:
    • There are some alert discrepancies. cs/invalid-string-formatting: The two added results are true positives (I didn't look into the cause of this as it could also be due to wobliness). cs/dereferenced-value-may-be-null: 15 alerts removed, I looked into this change. The alert was a false positive (so fine it is removed). The cause of the discrepancy is because the class of dereferences inspected by the query, in some corner cases for extension methods, depends on whether a parameter is from library code (as a heuristic). With the change in this PR, we use the location of the unbound declaration of a parameter and if this has a source location, it is no longer considered as being from a library (with the change in this PR the this parameter of Select now has a source location). Overall, I think this is in line with the intention of the heuristic.
    • No changes in performance.
    • Reduction in TRAP size of around 1%.

@github-actions github-actions bot added the C# label Oct 9, 2025
@michaelnebel michaelnebel requested a review from hvitved October 10, 2025 09:48
@michaelnebel michaelnebel marked this pull request as ready for review October 10, 2025 09:48
@michaelnebel michaelnebel requested a review from a team as a code owner October 10, 2025 09:48
Copilot AI review requested due to automatic review settings October 10, 2025 09:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@michaelnebel michaelnebel merged commit ab9f78f into github:main Oct 10, 2025
27 of 30 checks passed
@michaelnebel michaelnebel deleted the csharp/unboundlocations branch October 10, 2025 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants